using Common;
using DMTroube_ZeKer.Control;
using DMTroube_ZeKer.Model;
using DMTroube_ZeKer.View.ToolView;
using Newtonsoft.Json;
using System.Windows.Forms;
using static DMTroube_ZeKer.View.GiftPage;

namespace DMTroube_ZeKer
{
    public partial class Main : Form
    {
        public static List<LW>? lwlist;
        TopNation? _topNation;
        MainWebView? _webView;
        ControlTool? _controlTool;
        public Main()
        {
            InitializeComponent();

            #region 获取礼物列表
            string absolutePath = System.IO.Path.GetFullPath("./Resources/Data/lw.json");

            string jsonlw = JsonHelper.GetJsonFile(absolutePath);
            jsonlw = jsonlw.Replace("\"System.Drawing.Bitmap\"", null);
            if (!string.IsNullOrWhiteSpace(jsonlw))
            {
                lwlist = JsonConvert.DeserializeObject<List<LW>>(jsonlw);
            }
            #endregion

            #region Webview
            MainWebView webView = new MainWebView();
            webView.Dock = DockStyle.Fill;
            _webView = webView;
            #endregion

            #region 顶部
            TopNation topNation = new TopNation(webView);
            topNation.Dock = DockStyle.Fill;
            _topNation = topNation;
            #endregion

            #region 右侧
            ControlTool controlTool = new ControlTool(webView);
            PinLunTool pinLunTool = new PinLunTool(webView);
            GiftContent giftContent = new GiftContent(webView);
            controlTool.Dock = DockStyle.Fill;
            pinLunTool.Dock = DockStyle.Fill;
            giftContent.Dock = DockStyle.Fill;

            this.dmTroubePanle1.Tools = new List<TabData>()
            {
                new TabData()
                {
                    Name="控制台",
                    Control=controlTool
                },
                new TabData()
                {
                    Name="评论区",
                    Control=pinLunTool
                }
                ,
                new TabData()
                {
                    Name="礼物区",
                    Control=giftContent
                }
            };
            _controlTool = controlTool;
            #endregion

            this.dmTroubePanle1.MainControl_Top = topNation;
            this.dmTroubePanle1.MainControl_Left = webView;
        }

        private void TopNation_NationBtnClick(object arg1, string arg2)
        {

        }



        private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}